#!/bin/bash
####################################
# mysql db recover  #MDB
# 备份数据保存7天
####################################


#---------------------------参数
mdb_backup_file=/opt/backup/0401,backu_5_  #恢复的文件 /opt/backup/0401,backu_5_ 


mdb_database_user='root'
mdb_database_pass='wscdq815'
mdb_database_host='61.164.81.188' #127.0.0.1 不能用

#mdb_database_port='3306'
mdb_database_port='3302'


#-----------------------内部变量
_mdb_dump_arg=''
_mdb_split_arg=''
_mdb_pipe_file='/tmp/mdb_recover_pipe'

#通道文件
if [ ! -p   $_mdb_pipe_file ]
then 
	if [ -e $_mdb_pipe_file ]
	then 
		rm -fr $_mdb_pipe_file
	fi
	mkfifo $_mdb_pipe_file
fi 

echo $_mdb_split_arg
#-------------合并
echo "cat ${mdb_backup_file}* > $_mdb_pipe_file &"

#-------------导入

_mdb_dump_arg=${_mdb_dump_arg}" -u ${mdb_database_user}   -p${mdb_database_pass}   "
_mdb_dump_arg=${_mdb_dump_arg}" -h ${mdb_database_host} -P ${mdb_database_port}    "



#---------------输入
echo "cat $_mdb_pipe_file | mysql $_mdb_dump_arg  & "

_mdb_dump_state=$( echo $?)  #????
echo dump_state $_mdb_dump_state
	

 


